#include <stdio.h>
#include <stdlib.h>

void print_arr(int arr[], int n)
{
    int i;
    for(i = 0; i < n; i++)
    {
        printf("%d ", arr[i]);
    }
    putchar('\n');
}

void swap(int* a, int* b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void selection_sort(int arr[], int n)
{
    int i, j, min;
    for(i = 0; i < n; i++)
    {
        min = i;
        for(j = i + 1; j < n; j++)
        {
            if(arr[j] < arr[min])
                min = j;
        }
        swap(&arr[i], &arr[min]);
        print_arr(arr, n);
    }
}

int main()
{
    int arr[] = {1, 3, 6, 2, 15, 2, 6, 9, 4, 3};
    print_arr(arr, 10);
    selection_sort(arr, 10);
    return 0;
}
